<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!-- 增加，更新窗口 -->
<div id="SaveOrUpdateDevWin"
	style="width: 700px; height: 400px; padding: 10px;"
	class="easyui-dialog" title="权限信息"
	data-options="modal:true,closed:true,minimizable:false,collapsible:false,maximizable:false,buttons:'#bb',iconCls:'icon-save',onClose:function(){$('#saveOrUpdateDevForm')[0].reset();} ">
	<form id="saveOrUpdateDevForm" method="post" enctype="multipart/form-data" >
		<div class="menu_form_body">
			<input type="hidden" id="saveLx" name="saveLx"/>
			<table border="0" cellpadding="0" cellspacing="0" width="100%">
				<tr id="ridtr" style="display:none;width: 100%;">
					<td align="right" width="72" height="40" class="tangchukuangliebiao1">角色编号：</td>
					<td align="left" width="188" class="tangchukuangliebiao1">
						<input type="text" id="rid" name="rid" readonly="readonly" class="shurukuangkais" />
					</td>
					<td align="right" class="tangchukuangliebiao1"></td>
					<td align="left" width="188" class="tangchukuangliebiao1"></td>
				</tr>
				<tr>
					<td align="right" width="72" height="40" class="tangchukuangliebiao1">角色名称：</td>
					<td align="left" width="188" class="tangchukuangliebiao1">
						<input type="text" id="rname" name="rname" class="shurukuangkais" />
					</td>
					<td align="right" class="tangchukuangliebiao1">角色有效期：</td>
					<td align="left" width="188" class="tangchukuangliebiao1">
						<input type="text" id="jsyxqStr" name="jsyxqStr" class="easyui-datebox"  data-options="showSeconds:false,editable:false"/>
					</td>
				</tr>
				<tr>
					<td align="right" width="72" height="40" class="tangchukuangliebiao1">登录IP限制：</td>
					<td align="left" width="188" colspan="3" class="tangchukuangliebiao1">
						<input type="text" id="ipks" name="ipks" class="shurukuangkais" style="width: 100px;float: none">
						&nbsp;-&nbsp;
						<input type="text" id="ipjs" name="ipjs" class="shurukuangkais"  style="width: 100px;float: none"/>
 						<span style="font-size: 10px;">例：192.168.1.1-192.168.1.100</span>
					</td>
				</tr>
				<tr>
					<td align="right" width="72" height="40" class="tangchukuangliebiao1">审核权限：</td>
					<td align="left" width="188" colspan="3" class="tangchukuangliebiao1">
						&nbsp;&nbsp;<input type="radio" name="shqx" value="0">无审核权限&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="radio" name="shqx" value="1">有审核权限
					</td>
				</tr>
				<tr>
					<td align="right" width="72" height="40"
						class="tangchukuangliebiao1">权限列表：</td>
					<td align="left" width="188" colspan="3" class="tangchukuangliebiao1">
						<div style="height: 216px; overflow-y: auto;">
							<ul id="menuTree">
							</ul>
						</div>
					</td>
				</tr>
			</table>
		</div>
	</form>
</div>
<div id="bb">
	<a href="javascript:updateDev()" class="easyui-linkbutton">保存</a>
	<a href="javascript:cancelUpdateDev()" class="easyui-linkbutton">取消</a>
</div>

<script type="text/javascript">
$(function(){
// 	using('tree',function(){
// 		findTreeData();
// 	}); 
	findMenuTreeData();
});

function findMenuTreeData(){
	var rid = '${user.rid}';
	$("#menuTree").tree({
		checkbox:true,
		animate: true,
		lines:true,
		url:'${ctx}/menu/findRoleMenuTreeByRid.htm?rid='+rid+'&isBuild=true',//得到所有菜单拼装成树图
		onLoadSuccess:function(){
			//findRoleMenuTree();
		}
	});
}
function findRoleMenuTree(rid){
	var cked = $("#menuTree").tree("getChecked")
	$.each(cked,function(i,n){
	    $("#menuTree").tree("uncheck", n.target);
	}); 
	$.ajax({
		url:'${ctx}/menu/findRoleMenuTreeByRid.htm',//查询角色拥有的菜单，不拼装成树图
		data:{
			rid:rid,
			isBuild:false
		},
		cache:false,  
        dataType:'json',
        type:'post',
        success:function(data){  
        	$(data).each(function(i,obj){
				var n = $("#menuTree").tree('find',obj.id);
				if(n && (""== n.children)){//只获取末级节点
					$("#menuTree").tree('check',n.target);//选中所有末级节点
				}
			});
        }
	});
}

</script>